package cn.net.xyan.easy.webapp.base.service;

import cn.net.xyan.easy.webapp.base.api.dto.*;
import cn.net.xyan.easy.webapp.base.entity.Permission;
import cn.net.xyan.easy.webapp.base.entity.PermissionGroup;
import cn.net.xyan.easy.webapp.base.entity.SystemUser;
import org.springframework.data.domain.*;
import org.springframework.security.core.userdetails.UserDetailsService;

import java.util.List;

/**
 * Created by xiashenpin on 16/1/24.
 */
public interface ISecurityService  extends UserDetailsService {

    Integer Add = 1;
    Integer Remove = 2;

    String SUPERUSER = "admin";
    String SUPERPermission = "ADMIN";
    String USERPermission = "USER";

    Integer ActiveStatus = 1;
    Integer InActiveStatus = 2;

    String ActiveStatusTitle = "Active";
    String InActiveStatusTitle = "InActive";

    Boolean isUserNameExist(String user);
    SystemUser queryUserByUsername(String username);
    SystemUser registerUser(CommitRegisterUserReq req);
    SystemUser updateUser(CommitUpdateUserReq req);
    SystemUser updateUserPermission(CommitUpdatePermissionForUserReq req);
    SystemUser setupUser(String username,String password,Permission permission);

    Page<SystemUser> allUsers(org.springframework.data.domain.Pageable pageable);

    SystemUser currentUser();

    PermissionGroup createPermissionGroup(CommitCreatePermissionGroupReq req);
    PermissionGroup updatePermissionGroup(CommitUpdatePermissionGroupReq req);
    PermissionGroup queryPermissionGroupByGroupName(String groupName);

    Permission setupPermission(String permission,String describe);

    Boolean checkPermissionForUser(SystemUser user,Permission ...permissions);
    Boolean checkPermissionForUser(SystemUser user,List<Permission> permissions);

    List<Permission> queryPermissionForUser(SystemUser user);


}
